/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DAO.cadastro;

import DAO.DAO;
import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 *
 * @author pjoel002
 */
public class CadastroPaciente {

    public boolean inserirPaciente(int matricula, int idConvenio, String nome, 
                                   String nomemae, String endereco, String cep, 
                                   String bairro, String cidade, String uf,String titular,
                                   int rg,int cpf,String nomepai,String obs) {
        
        DAO banco = new DAO("mysql");
        boolean resposta = false;
        banco.conectarBanco();

        String query;
        query = "insert into paciente (matricula , ";
        query += "idConvenio , ";
        query += "nome , ";
        query += "nomeMae, ";
        query += "endereco , ";
        query += "cep , ";
        query += "bairro, ";
        query += "cidade, ";
        query += "uf , ";
        query += "titular , ";
        query += "rg , ";
        query += "cpf , ";
        query += "nomePai, ";
        query += "obs ) ";
        query += "values (?,?,?,?,?,?,?,?,?,?,?,?,?,?)";


        try {
            PreparedStatement pstmt;
            pstmt = banco.preparaInsert(query);
            pstmt.setInt(1, matricula);
            pstmt.setInt(2, idConvenio);
            pstmt.setString(3, nome);
            pstmt.setString(4, nomemae);
            pstmt.setString(5, endereco);
            pstmt.setString(6, cep);
            pstmt.setString(7, bairro);
            pstmt.setString(8, cidade);
            pstmt.setString(9, uf);
            pstmt.setString(10, titular);
            pstmt.setInt(11, rg);
            pstmt.setInt(12, cpf);
            pstmt.setString(13, nomepai);
            pstmt.setString(14, obs);
            pstmt.execute();
            resposta = true;

        } catch (SQLException ex) {
            throw new UnsupportedOperationException("Erro ao inserir o paciente no banco!");
        } finally {
            banco.desconectarBanco();
        }
        return resposta;
    }
}
